import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * @Description
 * @Author zhaobaolin
 * @Date 2018/10/24
 */
public class PriorityQueueTest {

    public static void main(String[] args) {
        handle();
    }

    private static void create()
    {
        PriorityQueue<Integer> a1 = new PriorityQueue<>();
        PriorityQueue<Integer> a2 = new PriorityQueue<>(Arrays.asList(2,5,3));
        PriorityQueue<Integer> a3 = new PriorityQueue<>(Comparator.reverseOrder());//指定排序比较器
    }

    private static void handle()
    {
        PriorityQueue<Integer> a1 = new PriorityQueue<>(Comparator.naturalOrder());
        a1.add(88);
        a1.add(34);
        a1.add(54);
        a1.add(26);
        a1.add(62);
        a1.add(19);
        System.out.println(a1);//output：[19, 34, 26, 88, 62, 54]

        a1.remove();//默认删除队列最前端元素
        System.out.println(a1);//output：[26, 34, 54, 88, 62]

        a1.remove(54);//删除指定元素
        System.out.println(a1);//output：[26, 34, 62, 88]

        a1.offer(3);//往队列出口压入元素
        System.out.println(a1);//output：[3, 26, 62, 88, 34]

        System.out.println(a1.peek());//偷看元素 output：3

        System.out.println(a1);//output：[3, 26, 62, 88, 34]

        System.out.println(a1.poll());//弹出元素 output：3

        System.out.println(a1);//output：[26, 34, 62, 88]
    }



}
